function qs = ElnpZ_pi_losses(mix, vars)

% E[ln p(Z|pi)]
    
[N K] = size(vars.Z);

qs = zeros(1, K);
for k = 1:K
    comps = [1:(k-1) (k+1):K];
    Z = vars.Z(:, comps) + realmin;
    Z = Z./(sum(Z, 2)*ones(1, K-1));

    if isfield(mix.varprior, 'a0')
        a = mix.varposterior.a;
        exp_logmix = dirichletln_exp(a(comps));
    else
        exp_logmix = log(mix.priors(comps)/sum(mix.priors(comps))+realmin);
    end
    
    qs(k) = sum(sum(Z.*(ones(N, 1)*exp_logmix)));
end
